package com.eks.nacos.user.controller;

import com.eks.nacos.user.config.CommonConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * UserController
 *
 * @author: chenfenghai
 * @version: 1.0
 * @date: 2021-01-21 14:37
 */
@RefreshScope
@RestController
public class UserController {

    @Autowired
    CommonConfig commonConfig;

    @Autowired
    private Environment env;

    @GetMapping("/getUserName")
    public String getUserName(){
        return "user-name: " + commonConfig.getUserName();
    }

    @GetMapping("/getCommonName")
    public String getCommonName(){
        return "common-name: " + commonConfig.getCommonName();
    }

    @GetMapping("/test1")
    public String test1() {
        return "UserController test1: " + env.getProperty("u.name", "env.default");
    }

    @GetMapping("/test2")
    public String test2(){
        return "UserController test2: " + env.getProperty("c.name", "env.default");
    }
}
